﻿#if UNITY_EDITOR
using System.IO;
using System.Runtime.CompilerServices;
/// <summary>
/// ResxTemplete工具类
/// </summary>
public partial class ESF_Utility
{
    #region TraceCaller_MemberName 代码调用成员名称
    /// <summary>
    /// 代码调用成员名称
    /// </summary>
    /// <param name="_memberName">成员名称</param>
    /// <returns>代码调用成员名称</returns>
    public static string TraceCaller_MemberName([CallerMemberName] string _memberName = "")
    {
        return _memberName;
    }
    #endregion

    #region TraceCaller_SourceFilePath 代码调用源文件路径
    /// <summary>
    /// 代码调用源文件路径
    /// </summary>
    /// <param name="_sourceFilePath">源文件路径</param>
    /// <returns>代码调用源文件路径</returns>
    public static string TraceCaller_SourceFilePath([CallerFilePath] string _sourceFilePath = "")
    {
        return _sourceFilePath;
    }
    #endregion

    #region TraceCaller_SourceLineNumber 代码调用源文代码行
    /// <summary>
    /// 代码调用源文代码行
    /// </summary>    
    /// <param name="_sourceLineNumber">源文代码行</param>
    /// <returns>代码调用源文代码行</returns>
    public static int TraceCaller_SourceLineNumber([CallerLineNumber] int _sourceLineNumber = 0)
    {
        return _sourceLineNumber;
    }
    #endregion

    #region TraceCaller_RelativeToAssetsParent 获得当前代码路径相对于Assets父目录路径
    /// <summary>
    /// 获得当前代码路径相对于Assets父目录路径
    /// </summary>
    /// <param name="_sourceFilePath">源文件路径</param>
    /// <returns>相对于Assets路径</returns>
    public static string TraceCaller_RelativeToAssetsParent([CallerFilePath] string _sourceFilePath = "")
    {
        return GetSubToAssets(Path.GetDirectoryName(_sourceFilePath));
    }
    #endregion

    #region TraceCaller_RelativeFrom 获得以当前代码路径为根路径的相对指定路径
    /// <summary>
    /// 获得以当前代码路径为根路径的相对指定路径
    /// </summary>
    /// <param name="_relavivePath">相对于当前代码路径的路径</param>
    /// <param name="_sourceFilePath">源文件路径</param>
    /// <returns>相对于Assets路径</returns>
    public static string TraceCaller_RelativeFrom(string _relavivePath = "", [CallerFilePath] string _sourceFilePath = "")
    {
        return SubToFilePath(_relavivePath, _sourceFilePath);
    }
    #endregion
}
#endif
